#ifndef __DRV_LAN8720_H_
#define __DRV_LAN8720_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "system.h"



enum
{
    LAN8720_STATUS_READ_ERROR = -5,
    LAN8720_STATUS_WRITE_ERROR = -4,
    LAN8720_STATUS_ADDRESS_ERROR = -3,
    LAN8720_STATUS_RESET_TIMEOUT = -2,
    LAN8720_STATUS_ERROR = -1,
    LAN8720_STATUS_OK = 0,
    LAN8720_STATUS_LINK_DOWN,               //连接断开
    LAN8720_STATUS_100MBITS_FULLDUPLEX,     //自动协商完成
    LAN8720_STATUS_100MBITS_HALFDUPLEX,     //100M全双工
    LAN8720_STATUS_10MBITS_FULLDUPLEX,      //100M半双工
    LAN8720_STATUS_10MBITS_HALFDUPLEX,      //10M全双工
    LAN8720_STATUS_AUTONEGO_NOTDONE,        //10M半双工
};

//LAN8720中断标志位定义
typedef enum
{
    LAN8720_IT_ENERGYON = 0x80,
    LAN8720_IT_AUTONEGO_COMPLETE = 0x40,
    LAN8720_IT_REMOTE_FAULT = 0x20,
    LAN8720_IT_LINK_DOWN = 0x10,
    LAN8720_IT_AUTONEGO_LP_ACK = 0x08,
    LAN8720_IT_PARALLEL_DETECTION_FAULT = 0x04,
    LAN8720_IT_AUTONEGO_PAGE_RECEIVED = 0x02,
} _drv_lan8720_it_e;



/* export func */

void drv_lan8720_init(void);

void drv_lan8720_mode_powerdown_enable(void);
void drv_lan8720_mode_powerdown_disaable(void);
void drv_lan8720_mode_loopback_enable(void);
void drv_lan8720_mode_loopback_disable(void);
void drv_lan8720_it_enable(_drv_lan8720_it_e interrupt);
void drv_lan8720_it_disable(_drv_lan8720_it_e interrupt);
void drv_lan8720_it_clear(_drv_lan8720_it_e interrupt);
uint8_t drv_lan8720_get_it_status(_drv_lan8720_it_e interrupt);
uint32_t drv_lan8720_get_link_status(void);
void drv_lan8720_set_link_status(int sta);

#ifdef __cplusplus
}
#endif

#endif // __DRV_LAN8720_H_
